<?php
namespace Tbf\Bundle\AlipayBundle\Api;

use Guzzle\Http\Url;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

use Tbf\Bundle\AlipayBundle\Entity\Transaction;
use Tbf\Bundle\AlipayBundle\Model\AlipaySign;
use Tbf\Bundle\AlipayBundle\Model\CreatePaymentRequest;
/**
 * 标准双接口处理类
 */
class CreateTradeByUser extends AbstractCreatePayment{
    protected function buildRequestData(CreatePaymentRequest $request){

        return array(
            '_input_charset'=>'utf-8',
            'notify_url'=>$this->config->getCtbuNotifyUrl(),
            'out_trade_no'=>$request->getTradeId(),
            'partner'=>$this->config->getAppKey(),
            'payment_type'=>1,
            'return_url'=>$this->config->getCtbuReturnUrl(),
            'service'=>'trade_create_by_buyer',
            'subject'=>$request->getSubject(),
            //'total_fee'=>$request->getMoney(),
            'sign_type'=>'MD5',
            'logistics_type'=>'EXPRESS', //物流类型(需要集成进系统?)
            'logistics_fee'=>'0.00',
            'logistics_payment'=>'BUYER_PAY', //物流支付类型
            'price'=>$request->getMoney(),
            'quantity'=>1,
            'receive_name'=>$this->handleReceiveName($request->getReceiveName()),
            'receive_address'=>$request->getReceiveAddress(),
            'receive_zip'=>$request->getReceiveZip(),
            'receive_phone'=>$request->getReceivePhone(),
            'receive_mobile'=>$request->getReceiveMobile(),
        );
    }
    protected function getCreatePaymentType(){
        return Transaction::TYPE_CREATE_TRADE_BY_USER;
    }
}